<%include file="header.html"%> <%include file="top.html"%> <%include
file="left.html"%>
<div class="main-content">
<div class="breadcrumbs" id="breadcrumbs"><script
	type="text/javascript">
	try {
		ace.settings.check('breadcrumbs', 'fixed')
	} catch (e) {
	}
</script>

<ul class="breadcrumb">
	<li><i class="icon-home home-icon"></i> <a
		href="index.php">首页</a></li>
</ul>
<!-- .breadcrumb --></div>

<div class="page-content">


<div id="moveDevice" style="display:none" class="col-xs-12">
<div class="alert alert-info">
<form class="form-horizontal" role="form">
<div class="row">

<div class="col-sm-12">
<div class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5">游戏</label>
<div class="col-sm-3"><select id="selectGame2">
	<option value="" >游戏</option>
	<%if $selectGames%> <%foreach from = $selectGames key = key item = value%>
	<%if $nowGame == $value %>
	<option value="<%$value%>" selected><%$value%></option>
	<%else%>
	<option value="<%$value%>"><%$value%></option>
	<%/if%> <%/foreach%> <%/if%>
</select>
</div>
</div>
</div>

<div class="col-sm-12">
<div  class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5"></label>
</div>
</div>

<div class="col-sm-12">
<div class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5">平台</label>
<div class="col-sm-3">
<select id="platform2">
	<option value="" id="selectPlatform">平台</option>
	<%if $platforms%> <%foreach from = $platforms key = key item = value%>
	<%if $platform == $value %>
	<option value="<%$value%>" selected><%$value%></option>
	<%else%>
	<option value="<%$value%>"><%$value%></option>
	<%/if%> <%/foreach%> <%/if%>
	
</select>
</div>
</div>
</div>


<div class="col-sm-12">
<div  class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5"></label>
</div>
</div>

<!--

<div class="col-sm-12">
<div class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5">渠道</label>
<div class="col-sm-3">
<select id="channel2">
	<option value="" id="selectChannel2">渠道</option>
	<%if $channels%> <%foreach from = $channels key = key item = value%>
	<%if $channel == $value %>
	<option value="<%$value%>" selected><%$value%></option>
	<%else%>
	<option value="<%$value%>"><%$value%></option>
	<%/if%> <%/foreach%> <%/if%>
</select>
</div>

</div>
</div>
-->

<div class="col-sm-12">
<div  class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5"></label>
</div>
</div>


<div class="col-sm-12">
<div  class="row">
<label class="col-sm-5 control-label no-padding-right" for="form-field-5"></label>
</div>
</div>

<div class="col-sm-12">
<div class="row"><label
	class="col-sm-5 control-label no-padding-right" for="form-field-5">&nbsp;&nbsp;&nbsp;&nbsp;</label>
<div class="col-sm-2">
<center>
<button type="button" onClick="formSubmit('select', 'move');"
	class="width-50 btn btn-sm btn-primary">配置</button>
</center>
</div>
</div>
</div>




</div>
</form>
</div>
</div>

<div id="pcDevice" style="display:block" class="col-xs-12">
<div class="alert alert-info">
<form class="form-horizontal" role="form">
<div class="row">

<div class="col-sm-2">
<div class="row">
<label class="col-sm-2 control-label no-padding-right" for="form-field-5">游戏</label>
<div class="col-sm-3"><select id="selectGame">
	<option value="" >游戏</option>
	<%if $selectGames%> <%foreach from = $selectGames key = key item = value%>
	<%if $nowGame == $value %>
	<option value="<%$value%>" selected><%$value%></option>
	<%else%>
	<option value="<%$value%>"><%$value%></option>
	<%/if%> <%/foreach%> <%/if%>
</select>
</div>
</div>
</div>


<div class="col-sm-2">
<div class="row">
<label class="col-sm-2 control-label no-padding-right" for="form-field-5">平台</label>
<div class="col-sm-3">
<select id="platform">
	<option value="" id="selectPlatform">平台</option>
	
	<%if $platforms%> <%foreach from = $platforms key = key item = value%>
	<%if $platform == $value %>
	<option value="<%$value%>" selected><%$value%></option>
	<%else%>
	<option value="<%$value%>"><%$value%></option>
	<%/if%> <%/foreach%> <%/if%>
	
</select>
</div>

</div>
</div>



<div class="col-sm-2">
<div class="row"><label
	class="col-sm-2 control-label no-padding-right" for="form-field-5">&nbsp;&nbsp;&nbsp;&nbsp;</label>
<div class="col-sm-9">
<center>
<button type="button" onClick="formSubmit('select', 'pc');"
	class="width-50 btn btn-sm btn-primary">配置
</button>
</center>
</div>
</div>
</div>


</div>
</form>
</div>
</div>



<div class="col-xs-12">
<div class="table-header">
<button type="button" 
	class="width-10 btn btn-sm btn-primary">服务器列表
</button>
</div>

	<div class="table-responsive">
		<table id="sample-table-1" class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<th>游戏</th>
					<th>平台</th>
					<th>名字</th>
					<th>ftpAddress</th>
					<th>ftpUser</th>
					<th>ftpPwd</th>
					<th>操作</th>
				</tr>
			</thead>

			<tbody>
			<%if $serverlist%>
			<%foreach from = $serverlist key = serverId item = serverlist%>
				<tr>
					<td><%$serverlist.s_game%></td>
					<td><%$serverlist.s_platform%></td>
					<td><%$serverlist.s_filename%></td>
					<td><%$serverlist.s_ftpaddress%></td>
					<td><%$serverlist.s_ftpuser%></td>
					<td><%$serverlist.s_ftppwd%></td>
					<td>
						<div class=" action-buttons">
							<a class="green" href="index.php?mod=ServerList&do=edit&id=<%$serverlist.s_id%>" >
								<i class="icon-pencil bigger-130"></i>&nbsp;编辑
							</a>
							&nbsp;
							<a class="green" target="_blank"  href="<%$serverlist.reViewUrl%>" >
								<i class="icon-eye-open bigger-130"></i>&nbsp;预览
							</a>
							<a class="green" target="_blank"  onclick="down(<%$serverlist.s_id%>);" >
							&nbsp;
								<i class="icon-eye-open bigger-130"></i>&nbsp;下载
							</a>
							&nbsp;
							<a class="green" target="_blank"   onclick="javascript:if(confirm('确认生效该服务器列表吗'))shengxiao(<%$serverlist.s_id%>);">
								<i class="icon-arrow-up bigger-130"></i>&nbsp;生效
							</a>
							
							<!-- <a class="red" href="javascript:if(confirm('确认删除吗?'))window.location='index.php?mod=User&do=delete&user_id=<%$user.user_id%>'" >
								<i class="icon-trash bigger-130"></i>&nbsp;删除
							</a> -->
						</div>
					</td>
				</tr>
				<%/foreach%>
				<%/if%>
			</tbody>
</table>
</div>



</div>
</div>
<!-- /.page-content --></div>
<!-- /.main-content -->
<script type="text/javascript">

	jQuery(function($) {
		$('.date-picker').datepicker({
			autoclose : true
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});

	});
	
	/**
	 生效
	*/
	function shengxiao(s_id) {
		alert(s_id);
	}
	
	/**
	 下载
	*/
	function down(s_id) {
		url = "index.php?mod=ServerList&do=download"
			+ "&s_id="
			+ s_id;
		window.location.href = url;
	}
	
	function formSubmit(type, device) {
		if(device == "pc") {
			var game = $('#selectGame').val();
			var platform = $('#platform').val();
		} else if(device == "move") {
			var game = $('#selectGame2').val();
			var platform = $('#platform2').val();
		}
		
		if (!game) {
			alert('请选择游戏');
		}  else {
				url = "index.php?mod=ServerList&do=configure&action=1&game="
					+ game
					+ "&platform="
					+ platform
					+ "&type="
					+ type;
			window.location.href = url;
		}
	}
	
	
	window.onload = function(){
		
		var width = document.documentElement.clientWidth;
		if(width < 1700) {
			$('#pcDevice').css("display", "none");
			$('#moveDevice').css("display", "block");
		} else if(width > 1700) {
			$('#pcDevice').css("display", "block");
			$('#moveDevice').css("display", "none");
		}
		
		// pc设备
	    var select = document.getElementById('selectGame');
	    select.onchange = function(){
	    	
	        // 更改值后执行的代码
	       var gameName = jQuery("#selectGame  option:selected").text();
	       var _tagNum = 1;
	       $.ajax({
	    	    type: "POST",
				url: "index.php?mod=Game&do=getPlatformByGame&game=" + gameName,
				data: "",
				dataType: 'html',
				success: function(data) {					
					var dataObj = eval("(" + data + ")");//转换为json对象
					
					if(dataObj == null) {
						$("#platform").empty();
						$("#platform").append('<option value="" id="selectPlatform">平台</option>');
					}
					
					var platform = dataObj.platform;
					$("#platform").empty();
					$("#platform").append('<option value="" id="selectPlatform">平台</option>');
					for(var i=0;i<platform.length;i++){
						$("#platform").append("<option value='"+platform[i]+"' >"+platform[i]+"</option>"+"<br/>");
					}
				}
	       });
	    }
	    
	    
	    // 移动设备
	    var select2 = document.getElementById('selectGame2');
	    select2.onchange = function(){
	        // 更改值后执行的代码
	       var gameName = jQuery("#selectGame2  option:selected").text();
	       $.ajax({
	    	    type: "POST",
				url: "index.php?mod=Game&do=getPlatformByGame&game=" + gameName,
				data: "",
				dataType: 'html',
				success: function(data) {					
					var dataObj = eval("(" + data + ")");//转换为json对象
					if(dataObj == null) {
						$("#platform2").empty();
						$("#platform2").append('<option value="" id="selectPlatform2">平台</option>');
					}
					
					var platform = dataObj.platform;
					$("#platform2").empty();
					$("#platform2").append('<option value="" id="selectPlatform2">平台</option>');
					for(var i=0;i<platform.length;i++){
						$("#platform2").append("<option value='"+platform[i]+"' >"+platform[i]+"</option>"+"<br/>");
					}
				}
	       });
	    }
	} 
	
</script>

<%include file="footer.html"%>

